\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{scmzu}[2016/09/11 1.0 South-Central University for Nationalities Thesis Template]

\LoadClass[12pt, a4paper, twoside, openany]{book}% 加载 \pkg{book} 类。
\RequirePackage[UTF8]{ctex}
\RequirePackage{ifxetex}%
\RequirePackage{etoolbox}%TeX扩展工具包
\RequirePackage{kvoptions}%键值对，参数和选项处理
\RequirePackage{xifthen}%条件处理宏包
\RequirePackage{geometry}%页面设置宏包
\RequirePackage{fancyhdr}%页眉和页脚设置宏包
\RequirePackage{setspace}%行距设置宏包
\RequirePackage{titletoc}%目录格式设置宏包
\RequirePackage{titlesec}%标题格式设置
\RequirePackage{indentfirst}%段落首行缩进
\RequirePackage[bottom,perpage,hang]{footmisc}%脚注设置宏包
\RequirePackage{pifont}%脚注带圈序号设置
\RequirePackage[hidelinks]{hyperref}%超链接和交叉引用宏包
\RequirePackage{xparse}
\RequirePackage{amsmath}%数学公式
\RequirePackage{amssymb}%符号
\RequirePackage{enumitem}%多级标题支持宏包
\RequirePackage[calc]{datetime2}%日期处理宏包
\RequirePackage[amsmath,thref,thmmarks]{ntheorem}% 定理类环境宏包，其中 amsmath 选项用来兼容 \AmSTeX\ 的宏包
\RequirePackage{listings}%格式化源程序（代码）
\RequirePackage[algoruled, linesnumbered, algochapter]{algorithm2e}%算法
\RequirePackage[square, super, comma, sort&compress]{natbib}%参考文献宏包
%\RequirePackage{cite}
\RequirePackage{xltxtra,xunicode}
\RequirePackage{xcolor}
\RequirePackage{kvoptions}
\RequirePackage{xstring}
\RequirePackage{graphicx}
\RequirePackage{svg}
\RequirePackage{setspace}
\RequirePackage{listings}

\makeatletter
%% kvoptions包设置
\SetupKeyvalOptions{%kvoptions包设置
    family=scmzu,
    prefix=scmzu@,
    setkeys=\kvsetkeys
}
%%文档模板参数定义
\DeclareStringOption[master]{degree}%学位类型:master硕士PMD专业硕士doctor博士bachelor本科
\DeclareBoolOption[true]{natural}%自然科学,否为社会科学
\DeclareBoolOption[false]{minor}%是否辅修本科学位论文
\DeclareBoolOption[false]{equivalent}%是否同等学历
\DeclareBoolOption[false]{secret}%涉密论文标志

\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessKeyvalOptions*

\def\isSecret{\boolean{scmzu@secret}}
\def\mydegree{\scmzu@degree}
\def\ThesisTitle{%
    \IfStrEqCase{\mydegree}{%
        {master}{硕士学位论文}%
        {PMD}{专业硕士学位论文}%
        {doctor}{博士学位论文}%
        {bachelor}{本科毕业论文（设计）}%
    }[学位类型缺失]
}

\newcommand{\defineterm}[1]{%
    \DeclareStringOption{zh@#1}
    \DeclareStringOption{en@#1}
    \expandafter\newcommand\csname #1\endcsname[2][]{%
        \ifthenelse{\isempty{##1}}{%then
            \setkeys{scmzu}{zh@#1=##2}%
        }{%else
            \setkeys{scmzu}{zh@#1=##1}%
            \setkeys{scmzu}{en@#1=##2}%
        }%
    }%
}

\newcommand{\myterm}[2][]{%
    \ifthenelse{\isempty{#1}}{\csname scmzu@zh@#2\endcsname}%
    {\IfStrEq{#1}{en}{\csname scmzu@en@#2\endcsname}{\csname scmzu@zh@#2\endcsname}}%
}

%论文信息
\defineterm{Title}%论文题目
\defineterm{SubTitle}%论文副标题
\defineterm{ClassificationNumber}%论文分类号
\defineterm{SecretYears}%保密年限
\defineterm{SecretLevel}%保密等级
\defineterm{Major}%学科专业
\defineterm{Category}%学科门类：工学|理学|法学|......
\defineterm{Direction}%研究方向
\defineterm{SubjectDate}%提交日期
\defineterm{DefenceDate}%答辩日期
\defineterm{Chairman}%答辩委员会主席
\defineterm{ChairmanTitle}%答辩委员会主席职称
%作者信息
\defineterm{Author}%作者姓名
\defineterm{StuID}%学号
\defineterm{University}%学校
\defineterm{UniversityCode}%学校代码
\defineterm{College}%学院
%作者本科毕业信息
\defineterm{bsDate}
\defineterm{bsUniversity}
%作者硕士毕业信息
\defineterm{msDate}
\defineterm{msUniversity}
%导师信息
\defineterm{Supervisor}%导师
\defineterm{SupervisorTitle}%职称
\defineterm{AssoSupervisor}%副导师
\defineterm{AssoSupervisorTitle}%副导师职称
\defineterm{CoSupervisor}%联合指导者
\defineterm{CoSupervisorTitle}%联合指导者职称

\defineterm{Abstract}%摘要
\defineterm{Keywords}%关键字

\geometry{%纸张大小
    a4paper, % 210 * 297mm
    hcentering,
    ignoreall,
    nomarginpar
}
\IfStrEq{\scmzu@degree}{bachelor}{%then
    \geometry{%
        left=3.17cm, right=3.17cm, top=2.54cm, bottom=2.54cm, 
        headheight=0.5cm, headsep=0.5cm, footskip=1cm}
}{%else
    \geometry{%
        left=2.5cm,right=2.5cm, top=2.2cm, headheight=0.8cm, headsep=0.5cm,
        bottom=2.2cm, footskip=1.1cm}
}%

\let\ClearDoublePage\cleardoublepage
\let\ClearPage\clearpage
\fancypagestyle{plain}{%
	\fancyhf{}
	\renewcommand{\footrulewidth}{0pt}
    \IfStrEq{\scmzu@degree}{bachelor}{%then
    	\fancyfoot[C]{\heiti\zihao{-5}\thepage}
	    \renewcommand{\headrulewidth}{0pt}
        \let\cleardoublepage\relax
        \let\clearpage\relax
    }{%else
    	\fancyfoot[C]{\heiti\zihao{5}\thepage}
    	\renewcommand{\headrule}{\hbox to \headwidth{\color{black}\leaders\hrule height \headrulewidth\hfill}\vskip -0.4cm \hbox to \headwidth{\color{black}\leaders\hrule height 0.5pt\hfill}}
	    \renewcommand{\headrulewidth}{2pt}
        \fancyhead[CO]{\songti\zihao{5}\myterm{University}\ThesisTitle}%
	    \fancyhead[CE]{\songti\zihao{5}\myterm{Title}}
    }
}

\renewcommand\frontmatter{%
    \ClearPage
    \pagestyle{empty}}

\renewcommand\mainmatter{%
	\ClearPage
	\pagestyle{plain}
    \pagenumbering{arabic}
    \setlength\parindent{2em}
    \setcounter{secnumdepth}{3}
	\setstretch{1.0}
    \IfStrEq{\mydegree}{bachelor}{\songti\zihao{5}}{\songti\zihao{-4}}
	\setlength{\parskip}{0pt}
	\setlength{\baselineskip}{20pt}  %行间距
}
\renewcommand\backmatter{\slearPage}


\def\takeTheRest#1\ofTheString\fi{\fi\@labeltext#1\wholeString}
\def\@labeltext#1#2\wholeString {%
    \if#2^%
    #1
    \else#1\hspace{\fill}\takeTheRest#2\ofTheString%
    \fi
}%
\newcommand{\insertspace}[1]{%
    \@labeltext#1^\wholeString%
}

\def\textboxed#1{\setlength{\fboxsep}{0pt}\raisebox{1pt}{\fbox{#1}}}
\newcommand{\BlankBox}{\textboxed{\color{white}$\surd$}}
\newcommand{\CheckedBox}{\textboxed{$\surd$}}

\makeatother

\def\Cover{%
    \vskip 2cm
    \heiti\zihao{-4}
    \parbox{26em}{
        \vskip 2cm
        \setstretch{2}
        \makebox[4em][s]{\insertspace{学校代号}}\underline{\makebox[7em]{\myterm{UniversityCode}}}%
        \hspace{\fill}%
        \makebox[4em][s]{\insertspace{学号}}\underline{\makebox[8em]{\myterm{StuID}}}%
    
        \makebox[4em][s]{\insertspace{分类号}}\underline{\makebox[7em]{\myterm{ClassificationNumber}}}%
        \hspace{\fill}%
        \makebox[4em][s]{\insertspace{密级}}\underline{\makebox[8em]{\ifthenelse{\isSecret}{\myterm{SecretLevel}}{~}}}%
    }
    \hspace{1.5em}
    \parbox{9em}{\vskip -1cm \includegraphics[height=2.88cm,width=2.8cm]{xiaohui.jpg}}

    \begin{center}
        \vskip 1.7cm
        \includegraphics[height=3.6cm,width=12cm]{xiaoming01.jpg}
        \vskip 1.4cm
        \heiti\zihao{0}\ThesisTitle
        \vskip 1.4cm
        \begin{center}
            \setstretch{1.5}\parbox[c][2.2cm]{38em}{\heiti\zihao{1}\centering\myterm{Title}}
        \end{center}
        \vskip 1.2em
        \begin{spacing}{1.8}
            \heiti\zihao{-4}
            \makebox[7em][s]{\insertspace{学位申请人姓名}}\underline{\makebox[7cm]{\songti \myterm{Author}}}

            \makebox[7em][s]{\insertspace{培养单位}}\underline{\makebox[7cm]{\songti \myterm{University}}}

            \makebox[7em][s]{\insertspace{导师姓名及职称}}\underline{\makebox[7cm]{\songti \myterm{Supervisor}~~\myterm{SupervisorTitle}}}

            \makebox[7em][s]{\insertspace{学科专业}}\underline{\makebox[7cm]{\songti \myterm{Major}}}

            \makebox[7em][s]{\insertspace{研究方向}}\underline{\makebox[7cm]{\songti \myterm{Direction}}}

            \makebox[7em][s]{\insertspace{论文提交日期}}\underline{\makebox[7cm]{\songti \myterm{SubjectDate}}}
        \end{spacing}
    \end{center}
    \clearpage
}

\def\PageTitle{%
    \newpage
    \setlength\parindent{1.5cm}
    \begin{flushleft}
        {\setstretch{1.2}\songti\zihao{5} ~\\~\\~\\~}\par
        \setstretch{1.8}\heiti\zihao{-4}
        \makebox[4em][s]{学校代号}：\myterm{UniversityCode}\par
        \makebox[4em][s]{\insertspace{学号}}：\myterm{StuID}\par
        \makebox[4em][s]{\insertspace{密级}}：\myterm{SecretLevel}\par
        {\setstretch{1.2}\songti\zihao{5} ~\\~\\~\\~}\par
        {\setstretch{1.2}\songti\zihao{-2}\textbf{\myterm{University}\ThesisTitle}}\par
        {\setstretch{1.5}\songti\zihao{5} ~\\~}\par
        {\setstretch{1.2}\heiti\zihao{2}\myterm{Title}}\par
        {\setstretch{1.5}\songti\zihao{5} ~\\~\\~\\~\\~}\par
        \setstretch{1.8}\heiti\zihao{-4}
        \underline{\makebox[7em][s]{学位申请人姓名}：\makebox[20em]{\songti \myterm{Author}}}\par
        \underline{\makebox[7em][s]{导师姓名及职称}：\makebox[20em]{\songti \myterm{Supervisor}~~\myterm{SupervisorTitle}}}\par
        \underline{\makebox[7em][s]{\insertspace{培养单位}}：\makebox[20em]{\songti \myterm{University}}}\par
        \underline{\makebox[7em][s]{\insertspace{专业名称}}：\makebox[20em]{\songti \myterm{Major}}}\par
        \underline{\makebox[7em][s]{\insertspace{论文提交日期}}：\makebox[20em]{\songti\myterm{SubjectDate}}}\par
        \underline{\makebox[7em][s]{\insertspace{论文答辩日期}}：\makebox[20em]{\songti\myterm{DefenceDate}}}\par
        \underline{\makebox[7em][s]{答辩委员会主席}：\makebox[20em]{\songti\myterm{Chairman}~~\myterm{ChairmanTitle}}}
    \end{flushleft}
    \clearpage
}

\def\EnPageTitle{%
    \newpage
    {\setstretch{1.2}\songti\zihao{5} ~\\~}\par
    \begin{center}
        \setstretch{2}\zihao{4}
        {\zihao{3}\myterm[en]{Title}}\par
        by \par
        \myterm[en]{Author} \par
        B.E.(\myterm[en]{bsUniversity})\myterm{bsDate}\par
        \IfStrEq{\mydegree}{doctor}{M.S.(\myterm[en]{msUniversity})\myterm{msDate}\par}{}
        A \IfStrEq{\mydegree}{doctor}{dissertation}{thesis} submitted in partial satisfaction of the\par
        Requirements for the degree of\par
        \IfStrEq{\mydegree}{doctor}{Doctor}{Master} of \myterm[en]{Category}\par
        in\par
        \myterm[en]{Major}\par
        in the\par
        Graduate School\par
        of\par
        \myterm[en]{University}\par
        ~\par
        Supervisor\par
        \myterm[en]{SupervisorTitle}~~\myterm[en]{Supervisor}\par
        \myterm{SubjectDate}
    \end{center}
    \clearpage
}

\def\copyrightpage{%学位论文原创性声明与版权使用授权书
    \newpage
    {\setstretch{1.2}\songti\zihao{5} ~}\par
    \setstretch{1.4}\songti\fontsize{13pt}{\baselineskip}\selectfont\setlength\parindent{2em}
    \begin{center}
        \heiti\zihao{-2}中南民族大学\\学位论文原创性声明
    \end{center} \par
    本人郑重声明：所呈交的论文是本人在导师的指导下独立进行研究所取得的研究成果。除了文中特别加以标注引用的内容外，本论文不包含任何其他个人或集体已经发表或撰写的成果作品。对本文的研究做出重要贡献的个人和集体，均已在文中以明确方式标明。本人完全意识到本声明的法律后果由本人承担。\par
    ~\par
    作者签名：\hskip 9em 日期：\hskip 2em \makebox[7em][s]{\insertspace{年月日}}\par
    ~\par
    \begin{center}
        \heiti\zihao{-2}学位论文版权使用授权书
    \end{center}\par
    本学位论文作者完全了解学校有关保留、使用学位论文的规定，同意学校保留并向国家有关部门或机构送交论文的复印件和电子版，允许论文被查阅和借阅。本人授权中南民族大学可以将本学位论文的全部或部分内容编入有关数据库进行检索，可以采用影印、缩印或扫描等复制手段保存和汇编本学位论文。\par
    本学位论文属于\par
    \setlength\parindent{9em}
    1、保密~\ifthenelse{\isSecret}{\CheckedBox}{\BlankBox}，在\underline{\makebox[3em]{\ifthenelse{\isSecret}{\secretYears 年}{}}}解密后适用本授权书。

    2、不保密~\ifthenelse{\isSecret}{\BlankBox}{\CheckedBox}。\par
    （请在以上相应方框内打“$\surd$”）\par
    ~\par
    \setlength\parindent{2em}
    作者签名：\hskip 7em 日期：\hskip 2em \makebox[7em][s]{\insertspace{年月日}}\par
    导师签名：\hskip 7em 日期：\hskip 2em \makebox[7em][s]{\insertspace{年月日}}
    \clearpage
}

\def\makeCover{%
    \frontmatter
    \IfStrEq{\mydegree}{bachelor}{%本科论文

    }{%研究生论文
        \newgeometry{left=3cm,right=3cm, top=3cm, bottom=3cm}
        \noindent
        \Cover
        \PageTitle
        \EnPageTitle
        \copyrightpage
        \restoregeometry
    }
    \newpage
}

%%目录
\renewcommand{\contentsname}{\tocTitlestyle 目~ ~录\\ }
\IfStrEq{\mydegree}{lbachelor}{%
	\def\tocTitlestyle{\heiti\zihao{4}}
	\def\tocHangStyle{\songti\zihao{5}}
}{%
	\def\tocTitlestyle{\heiti\zihao{4}}
	\def\tocHangStyle{\songti\zihao{-4}}
}
\makeatletter
\def\label@seperator@toc{%
    \IfStrEq{\mydegree}{bachelor}{%then
	    \ifthenelse{\boolean{scmzu@natural}}{\hspace{1em}}{\hspace{0em}}%
	}{%
        \hspace{1em}%
	}%
}%
\titlecontents{chapter}[0pt]{\tocHangStyle}%
    {%
	    \IfStrEq{\mydegree}{bachelor}{%then
	        \ifthenelse{\boolean{scmzu@natural}}{%then
	            \thecontentslabel%
	        }{%else
	            \zhnumber{\thecontentslabel}%
	        }%
	    }{%else
	        第\zhnumber{\thecontentslabel}章%
	    }%
		\label@seperator@toc%
    }%
    {}%
    {\titlerule*[0.5pc]{.}\contentspage}
\titlecontents{section}[2em]{\tocHangStyle}%
    {\thecontentslabel\label@seperator@toc}%
    {}%
    {\titlerule*[0.5em]{.}\contentspage}
\titlecontents{subsection}[4em]{\tocHangStyle}%
    {\thecontentslabel\label@seperator@toc}%
    {}%
    {\titlerule*[0.5em]{.}\contentspage}
\let\ori@tableofcontents\tableofcontents
\renewcommand{\tableofcontents}{%
	\setstretch{1}
	\setcounter{tocdepth}{2}
    \setcounter{page}{1}
    \pagenumbering{roman}
	\contentsmargin{1em}
    \ori@tableofcontents
    \newpage
}

%中文摘要
\newenvironment{cnAbstract}
{%
    
	\pagestyle{plain}\pagenumbering{Roman}
	\addcontentsline{toc}{chapter}{摘要}%
	\IfStrEq{\mydegree}{bachelor}%
	{%
		\songti\zihao{5}%
		\begin{center}
			\heiti\zihao{-2}\myterm{Title}
		\end{center}
		\vskip 1em
		\noindent\heiti\zihao{4}摘要：\songti\zihao{5}
		\baselinestretch{1.5}
	}{
		\songti\zihao{-4}%
		\chapter*{摘~要}
	}%
}%
{%
	\IfStrEq{\mydegree}{bachelor}%
	{}%
	{\newpage}%
}
%英文摘要
\newenvironment{abstract}
{%
	\pagestyle{plain}
	\addcontentsline{toc}{chapter}{ABSTRACT}%
	\IfStrEq{\mydegree}{bachelor}%
	{%
		\addcontentsline{toc}{chapter}{Abstract}%
		\begin{center}
			~\\ \sanhao\textbf{\myterm[en]{Title}}
		\end{center}
		\vskip 1em
		\noindent\sihao\textbf{Abstract: }\zihao{5}\setstretch{0.85}
		\baselinestretch{1.5}
	}%
	{%
		\songti\zihao{-4}\setstretch{0.85}
		\chapter*{ABSTRACT}
	}
}
{\newpage}

%关键字
\newcommand\keywords{%
	~\par
	\def\parselist##1{%
		\def\lastitem{##1}%
		\futurelet\next\getoneitem
	}
	\def\getoneitem{%
		\ifx\next\bgroup
		\let\go\getnextitem
		\else
		\let\go\getlastitem
		\fi
		\go
	}
	\def\getnextitem##1{%
		\lastitem;
		\def\lastitem{##1}%
		\futurelet\next\getoneitem
	}
	\def\getlastitem{\lastitem}%
	%
	\noindent\newline\rmfamily
	\textbf{\zihao{4} Keywords:}
	\let\go\parselist\go
}
\newcommand\cnKeywords{%
	~\par
	\def\parselist##1{%
		\def\lastitem{##1}%
		\futurelet\next\getoneitem
	}
	\def\getoneitem{%
		\ifx\next\bgroup
		\let\go\getnextitem
		\else
		\let\go\getlastitem
		\fi
		\go
	}
	\def\getnextitem##1{%
		\lastitem；
		\def\lastitem{##1}%
		\futurelet\next\getoneitem
	}
	\def\getlastitem{\lastitem}%
	%
	\noindent\newline
	{\heiti\zihao{4} 关键字：}
	\let\go\parselist\go
}

%%正文元素
%章节标题
\newcommand{\cdigit}[1]{%
    \ifcase#1{０}\or{１}\or{２}\or{３}\or{４}\or{５}\or{６}\or{７}\or{８}\or{９}\fi}
    
\IfStrEq{\mydegree}{bachelor}{%then
	\ifthenelse{\boolean{scmzu@natural}}{%then
	    \renewcommand{\chaptername}{\zhdigits{\thechapter}}%
        \def \label@seperator{1em}%
        \titleformat{\subsection}[hang]{\heiti\zihao{5}}{\thesubsection}{\label@seperator}{}%
        \titleformat{\subsubsection}[hang]{\heiti\zihao{5}}{\thesubsubsection}{\label@seperator}{}%
	}{%else
		\renewcommand{\chaptername}{\cdigit{\thechapter}、}%
        \renewcommand{\thesection}{（\cdigit{\arabic{section}}）}%
        \renewcommand{\thesubsection}{\cdigit{\arabic{subsection}}．}%
        \renewcommand{\thesubsubsection}{（\cdigit{\arabic{subsubsection}}）}%
        \def \label@seperator{0em}
        \titleformat{\subsection}[hang]{\heiti\zihao{5}}{\hspace{2em}\thesubsection}{\label@seperator}{}%
        \titleformat{\subsubsection}[hang]{\heiti\zihao{5}}{\hspace{2em}\thesubsubsection}{\label@seperator}{}%
	}%
	\titleformat{\chapter}[hang]{\heiti\zihao{4}}{\chaptername}{\label@seperator}{}
	\titleformat{\section}[hang]{\heiti\zihao{-4}}{\thesection}{\label@seperator}{}
	\titlespacing{\chapter}{0pt}{1em}{0.5em}
	\titlespacing*{\section}{0em}{0.5em}{*0}
	\titlespacing*{\subsection}{0em}{0em}{*0}
	\titlespacing*{\subsubsection}{0em}{0em}{*0}
}{%else
	\renewcommand{\chaptername}{第\zhnumber{\thechapter}章}
	\titleformat{\chapter}[hang]{\centering\heiti\zihao{-2}}{\chaptername}{1em}{}
	\titlespacing{\chapter}{0pt}{4pt}{*4}
	\titleformat{\section}[hang]{\heiti\zihao{-3}}{\thesection}{1em}{}
	\titleformat{\subsection}[hang]{\heiti\zihao{-4}}{\thesubsection}{1em}{}
	\titleformat{\subsubsection}[hang]{\heiti\zihao{-4}}{\thesubsubsection}{1em}{}
}

%%多级列表使用宏包enumitem，最多3级
\newenvironment{parList}
{
    \ifx\c@myparlistdepth\undefined{\newcounter{myparlistdepth}} \fi
    \stepcounter{myparlistdepth}
    \ifnum \value{myparlistdepth}=1
        \SetEnumitemValue{label}{labelformat}{\arabic*)}
    \else
        \ifnum \value{myparlistdepth}=2
            \SetEnumitemValue{label}{labelformat}{\roman*)}
        \else
            \SetEnumitemValue{label}{labelformat}{\alph*)}
        \fi
    \fi
    \setlist{label=labelformat, labelsep=0.5em, listparindent=2em, itemindent=2em, leftmargin=\parindent,
                parsep=0pt, itemsep=0pt, topsep=0pt
    }
    \IfStrEq{\mydegree}{bachelor}{\zihao{5}}{\zihao{-4}}%
    \begin{enumerate}
}
{
    \addtocounter{myparlistdepth}{-1}
    \end{enumerate}
    \par
}

%%行内列表
\def\ilnumFnt{\IfStrEq{\mydegree}{bachelor}{\zihao{6}}{\zihao{-5}}}%
\newcommand\inlinelist{%
    \def\parselist##1{%
        \def\lastitem{\addtocounter{ilitemscount}{1}\textcircled{\ilnumFnt\arabic{ilitemscount}} ##1}%
        \futurelet\next\getoneitem
    }%
    \def\getoneitem{%
        \ifx\next\bgroup
            \let\go\getnextitem
        \else
            \let\go\getlastitem
        \fi
        \go
    }%
    \def\getnextitem##1{%
        \lastitem
        \def\lastitem{\addtocounter{ilitemscount}{1}\textcircled{\ilnumFnt\arabic{ilitemscount}} ##1}%
        \futurelet\next\getoneitem
    }%
    \def\getlastitem{\lastitem}%
    %
    \ifx\c@ilitemscount\undefined{\newcounter{ilitemscount}}\else{\setcounter{ilitemscount}{0}}\fi
    \let\go\parselist\go
}

%使用定理环境的交叉引用，要加上thref选项；使用证明结束符，要加上thmmarks选项（？）
\theoremstyle{plain}%定理环境风格，plain是LaTeX的原始风格
\theoremheaderfont{\heiti}%定理头部字体
\theorembodyfont{}%定理内容字体
\theoremseparator{\hspace{1em}}%定理头部与内容间相隔的距离
\theoremnumbering{arabic}%定理的计数采用阿拉伯数字
\theoremsymbol{}%定理结束符
\newtheorem{Definition}{\hspace{2em}定义}[chapter]%定义定义环境名为definition，显示如“定义1.1.1”
\newtheorem{Axiom}{\hspace{2em}公理}[chapter]%定义公理环境名为axiom，显示如“公理1”
\newtheorem{Theorem}{\hspace{1em}定理}[chapter]
\newtheorem{Propsition}{\hspace{1em}命题}[chapter]
\newtheorem{Corollary}{\hspace{1em}推论}[chapter]
\newtheorem{Lemma}{\hspace{1em}引理}[chapter]
\newtheorem{Example}{\hspace{1em}例}[chapter]
\newtheorem{Exercise}{\hspace{1em}习题}[chapter]

%设置证明环境，仍然用的ntheorem宏包的定理环境
\theoremstyle{nonumberplain}%nonumberplain是不编号的定理环境
\theoremsymbol{\ensuremath{\Box}}%设置定理结束符
\newtheorem{Proof}{\hspace{2em}证}
\newtheorem{Solution}{\hspace{2em}解}
\newtheorem{Notation}{\hspace{2em}注}

\setlength{\theorempreskipamount}{0em}%调整定理环境与上文的距离
\setlength{\theorempostskipamount}{0em}%调整定理环境与下文的距离
%由于前面把“定理”字样改成了“　　定理”，所以直接引用\thref会在“定理”前加两个空格
%所以这里重定义\thref命令
\let\oldthref\thref
\renewcommand{\thref}[1]{\hspace{-2em}\oldthref{#1}}

\numberwithin{equation}{section}%使每节公式重新编号

%%图形
%%单个图形、多个图形
%%表格


%%公式
\renewcommand{\theequation}{\thechapter.\arabic{equation}}
\renewcommand{\eqref}[1]{公式\ref{#1}}
%%  行内公式
%%  行间公式

%%算法
%\renewcommand{\algorithmcfname}{\textbf{\heiti\zihao{5} 算法}}
\SetAlgorithmName{算法}{算法}{}
\SetAlgoProcName{过程}{过程}
\SetAlgoFuncName{函数}{函数}
\SetAlCapSty{textbf}
\SetAlCapNameSty{textbf}
\IfStrEq{\mydegree}{bachelor}{%
	\SetAlCapFnt{\heiti\zihao{5}}
	\SetAlCapNameFnt{\heiti\zihao{5}}
}{%
	\SetAlCapFnt{\heiti\zihao{-4}}
	\SetAlCapNameFnt{\heiti\zihao{-4}}
}
\newcommand{\Algorithm}[4]{%
	\vskip 0.5em
	\IncMargin{1em}
	\begin{algorithm}[!htb]
		\begin{spacing}{0.85}
			\IfStrEq{\mydegree}{bachelor}{\zihao{-5}}{\zihao{5}}%
			\caption{#1}
			\label{#1}
			\SetAlgoNoLine
			\SetKwInOut{Input}{输入}\SetKwInOut{Output}{输出}
			\Input{#2}
			\Output{#3}
			{ #4}
		\end{spacing}
	\end{algorithm}
	\IfStrEq{\mydegree}{bachelor}{\zihao{5}}{\zihao{-4}}%
	\DecMargin{1em}
	\vskip 0.5em
}
%%程序代码
\lstset{
  %language=Matlab,  %代码语言使用的是matlab
  frame=shadowbox, %把代码用带有阴影的框圈起来
  rulesepcolor=\color{red!20!green!20!blue!20},%代码块边框为淡青色
  keywordstyle=\color{blue!90}\bfseries, %代码关键字的颜色为蓝色，粗体
  commentstyle=\color{red!10!green!70}\textit,    % 设置代码注释的颜色
  showstringspaces=false,%不显示代码字符串中间的空格标记
  numbers=left, % 显示行号
  numberstyle=\tiny,    % 行号字体
  stringstyle=\ttfamily, % 代码字符串的特殊格式
  breaklines=true, %对过长的代码自动换行
  extendedchars=false,  %解决代码跨页时，章节标题，页眉等汉字不显示的问题
  texcl=true}


\lstset{breaklines}%自动将长的代码行换行排版

\lstset{extendedchars=false}%解决代码跨页时，章节标题，页眉等汉字不显示的问题

%%参考文献
\newcommand{\references}[1]{%
    \phantomsection
	\IfStrEq{\mydegree}{bachelor}{%
		~\par
		\renewcommand{\bibfont}{\songti\zihao{-5}}
		\renewcommand\bibname{\centerline{\heiti\zihao{4} 参考文献}\\ }%
	}{%
		\renewcommand{\bibfont}{\songti\zihao{5}}
		\renewcommand\bibname{\centerline{\heiti\zihao{-2} 参考文献}}%
		\clearpage
	}
	\addcontentsline{toc}{chapter}{参考文献}%
	\IfStrEq{\mydegree}{bachelor}{%then
	    \def\bibstyltname{bachelor}%
	}{%else
	    \def\bibstyltname{graduate}%
	}
	\ifthenelse{\boolean{scmzu@natural}}{%
	    \bibliographystyle{\bibstyltname .nat}%
	}{%
	    \bibliographystyle{\bibstyltname .soc}%
	}
	\renewcommand\bibsection{\chapter*{\bibname}}
	\setlength{\bibsep}{0.4em}
	\begin{spacing}{0.85}
	\bibliography{#1}%
	\end{spacing}
	\clearpage
}

%% 致谢
\newenvironment{acknowledgement}
{%
    \phantomsection
	\addcontentsline{toc}{chapter}{致谢}%
	\IfStrEq{\mydegree}{bachelor}{%
		~\par
		\chapter*{\centerline{\heiti\zihao{4}	致\hspace{1em}谢}}%
	}{%
		\chapter*{致谢}%
    }%
}{%
	\IfStrEq{\mydegree}{bachelor}%
	{}%
	{\clearpage}%
}%

%%附录


\makeatother